<%@ page import="fun.scxsh.webproject.entity.Student" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/12/16
  Time: 15:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<h2>学生列表</h2>
<table border="1">
    <tr>
        <th>ID</th>
        <th>姓名</th>
        <th>年龄</th>
    </tr>
    <%
        List<Student> studentList = (List<Student>)
                request.getAttribute("studentList");
        if (studentList!= null &&!studentList.isEmpty()) {
            for (Student student : studentList) {
    %>
    <tr>
        <td><%=student.getId()%></td>
        <td><%=student.getName()%></td>
        <td><%=student.getAge()%></td>
    </tr>
    <%
            }
        }
    %>
</table>
    <div>
        当前第 <%=request.getAttribute("pageNum")%> 页，共
        <%=request.getAttribute("totalPages")%> 页
        <%
            int pageNum = (int) request.getAttribute("pageNum");
            if (pageNum > 1) {
        %>
        <a href="student?pageNum=<%=pageNum - 1%>">上一页</a>
        <%
            }
            if (pageNum < (int) request.getAttribute("totalPages")) {
        %>
        <a href="student?pageNum=<%=pageNum + 1%>">下一页</a>
        <%
            }
        %>
    </div>
</body>
</html>
